Mac 终端环境配置

基础工具安装

homebrew

官网https://brew.sh/
安装

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

替换清华源

1
2
3
4
5
6
7
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update

还原回官方源(如果镜像无法使用)

1
2
3
4
5
6
7
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

替换Bottles源

1
2
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

zsh

使用brew安装zsh

1
brew install zsh

iTerm2

下载安装https://iterm2.com
配置item2的shell为zsh
image.png

oh-my-zsh

安装 https://ohmyz.sh

1
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装powerline字体

1
brew install powerlevel9k

powerline配置

在~/.zshrc中配置ZSH_THEME

1
ZSH_THEME="powerlevel9k/powerlevel9k"

oh-my-zsh插件

插件列表

  1. https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins
  2. https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

在~/.zshrc中增加如下配置安装插件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
plugins=(
git
brew
node
nvm
kubectl
helm
z
vi-mode
zsh-syntax-highlighting
zsh-autosuggestions
osx
colored-man-pages
catimg
web-search
vscode
docker
docker-compose
copydir
copyfile
npm
yarn
extract
fzf
)
0%